package xin.vote.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import xin.vote.dao.UsersMapper;
import xin.vote.model.Users;
import xin.vote.service.IUserService;

@Service
public class UserService implements IUserService{

	@Resource
	private UsersMapper userMapper;

	//普通用户登录
	@Override
	public Users findUserByNameAndPwd(Users u) {
		return userMapper.selectByNameAndPassword(u);
	}
	
	//普通用户注册
	@Override
	public int addUserSelective(Users u) {
		return userMapper.insertSelective(u);
	}

	//通过用户名查找用户(注册查重)
	@Override
	public Users findUserByAccount(String userLoginName) {
		return userMapper.selectByAccount(userLoginName);
	}

	//查找所有普通用户
	@Override
	public List<Users> findAllCommonUsers() {
		return userMapper.selectAllCommonUsers();
	}

	//顶部动态查询用户
	@Override
	public List<Users> findUsersDynamic(Users u) {
		return userMapper.selectUsersDynamic(u);
	}

	//通过UserId选择性编辑用户
	@Override
	public int updateByPrimaryKeySelective(Users u) {
		return userMapper.updateByPrimaryKeySelective(u);
	}

	//通过UserId删除用户
	@Override
	public int deleteByPrimaryKey(Integer userid) {
		return userMapper.deleteByPrimaryKey(userid);
	}

	//添加用户
	@Override
	public int insertUser(Users u) {
		return userMapper.insertUser(u);
	}

	@Override
	public Users adminLogin(Users u) {
		// TODO Auto-generated method stub
		return userMapper.adminLogin(u);
	}

}
